<script>
	export default {
		onLaunch: function() {
			getApp().globalData.img_pre = this.img_pre;
			getApp().globalData.url_p = this.update_urls;
		},
		onShow: function() {
			var _this = this;
			//#ifdef APP-PLUS
			plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
				if (uni.getSystemInfoSync().platform === 'android') {
					var url = _this.update_url + "appstore/package/androidCheck";
				} else if (uni.getSystemInfoSync().platform === 'ios') {
					var url = _this.update_url + "appstore/package/iosCheck";
				} else {
					console.log('运行其他上')
					return false
				}
				uni.request({
					url: url,
					data: {
						appVersion: widgetInfo.version,
						appId: plus.runtime.appid
					},
					method: "POST",
					dataType: "json",
					success: (res) => {
						var data = res.data.result;
						if (data.update) {
							if (data.wgtURL) {
								_this.$u.route(
									"/uview-ui/components/u-full-screen/u-full-screen?id=1");
								const downloadTask = uni.downloadFile({
									url: data.wgtURL,
									success: (downloadResult) => {
										console.log(downloadResult);
										if (downloadResult.statusCode === 200) {
											plus.runtime.install(downloadResult
												.tempFilePath, {
													force: false
												},
												function(e) {
													console.log(e);
													plus.runtime.restart();
												},
												function(e) {
													console.log(e);
													/* plus.runtime.restart(); */
												});
										}
									}
								});
								downloadTask.onProgressUpdate((res) => {
									uni.$emit('update', {
										number: res.progress
									})
								});
							}
							if (data.pkgURL) {
								uni.showModal({
									title: "更新提示",
									content: data.note,
									success: (res) => {
										if (res.confirm) {
											plus.runtime.openURL(data.pkgURL);
										} else {
											if (uni.getSystemInfoSync().platform ===
												'android') {
												plus.runtime.quit();
											} else if (uni.getSystemInfoSync()
												.platform === 'ios') {
												plus.ios.import("UIApplication")
													.sharedApplication()
													.performSelector("exit");
											} else {
												return false
											}
										}
									}
								})
							}
						}
					},
					fail: (res) => {
						console.log(res);
					}
				});
			});
			//#endif
		},
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";

	.u-text-center {
		padding: 0 60rpx;

		.u-text-name {
			font-size: 38rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #333333;
			line-height: 115rpx;
			height: 115rpx;
		}

		.u-text-abc {
			display: flex;
			align-items: center;
			margin-bottom: 50rpx;

			image {
				width: 42rpx;
				height: 42rpx;
			}

			.u-text-dat {
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #666666;

				text {
					color: #F2B60E;
				}
			}
		}

		.u-text-text {
			line-height: 48rpx;
			margin-bottom: 10rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #666666;
		}
	}

	.none {
		text-align: center;
		width: 678rpx;
		height: 460rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: auto;

		.none-view {

			.none-image {
				width: 226.4rpx;
				height: 213.7rpx;
			}

			.none-name {
				margin-top: 57rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #A29C9C;
			}
		}
	}


	.omit {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.omit2 {
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
</style>
